package com.hx.petsever.controller.manage;

import com.hx.petsever.config.Result;
import com.hx.petsever.entity.adminAccount;
import com.hx.petsever.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/back/user")
@CrossOrigin(origins="http://localhost:9999")
public class AdminController {

    @Autowired
    AdminService adminService;

    @PostMapping("/login")
    public Result user(adminAccount account) {
        System.out.println("控制器"+account);
        Map loginMsg = adminService.login(account);
        Result<Map> result = new Result<>();
        if(loginMsg == null) result.fail("账号密码错误！");
        else result.setData(loginMsg);
        return  result;
    }

}
